﻿using hCommand;
using Microsoft.Win32.SafeHandles;
using Net.http;
using System;

namespace Persistence {
    /**
   *┌────────────────────────────────────────────────┐
   *│　描    述：Component                                                    
   *│　作    者：sgj                                              
   *│　版    本：1.0                                              
   *│　创建时间：2020/9/2 11:28:16                        
   *└────────────────────────────────────────────────┘
   **/
    public class CsdUtil {

        public const String param_value_remain = "remain";

       



        static public CoreStockDet split(Sw sw, CoreStockDet old, double nowOutCount) {
            if (same(nowOutCount, old.countDb)) {
                return old;
            }

            if (nowOutCount < old.countDb) {

                CoreStockDet model = (CoreStockDet)old.Clone();
                model.id = 0;
                model.countDb = old.countDb - nowOutCount;

                sw.insert(model);

                old.countDb = nowOutCount;
                string sql = "update  core_stock_det set count_Db=@countDb where id=@Id";
                sw.exec(sql, old);

            }
            return old;
        }

        static public bool same(double v1, double v2) {
            return Math.Abs(v1 - v2) < loss;
        }
        public const double loss = 0.000001;
    }
}
